#include <basic_types.h>
#include <api/libc/alloc.h>
#include <api/libc/printf.h>
#include <osal/osal.h>

#include <hld/hld_dev.h>
#include <hld/sdec/sdec.h>
#include <hld/sdec/sdec_dev.h>


#ifdef DUAL_ENABLE
#include <modules.h>

enum HLD_SDEC_FUNC{
    FUNC_SDEC_OPEN = 0,
    FUNC_SDEC_CLOSE,
    FUNC_SDEC_START,
    FUNC_SDEC_STOP,
    FUNC_SDEC_PAUSE,
};

#ifndef _HLD_SDEC_REMOTE
UINT32 hld_sdec_entry[] = 
{
    (UINT32)sdec_open,
    (UINT32)sdec_close,
    (UINT32)sdec_start,
    (UINT32)sdec_stop,
    (UINT32)sdec_pause,
};

void hld_sdec_callee(UINT8 *msg)
{
    OS_hld_callee(hld_sdec_entry, msg);
}
#endif

#ifdef _HLD_SDEC_REMOTE

/*
 * 	Name		:   sdec_open()   	
 *	Description	:   Open a sdec device
 *	Parameter	:	struct sdec_device *dev		: Device to be openned
 *	Return		:	INT32 						: Return value
 *
 */
INT32 sdec_open(struct sdec_device *dev)
{
    jump_to_func(NULL, OS_hld_caller, dev, (HLD_SDEC_MODULE<<24)|(1<<16)|FUNC_SDEC_OPEN, NULL);
}

/*
 * 	Name		:   sdec_close()   	
 *	Description	:   Close a sdec device
 *	Parameter	:	struct sdec_device *dev		: Device to be closed
 *	Return		:	INT32 						: Return value
 *
 */
INT32 sdec_close(struct sdec_device *dev)
{
    jump_to_func(NULL, OS_hld_caller, dev, (HLD_SDEC_MODULE<<24)|(1<<16)|FUNC_SDEC_CLOSE, NULL);
}

INT32  sdec_start(struct sdec_device *dev,UINT16 composition_page_id,UINT16 ancillary_page_id)
{
	jump_to_func(NULL, OS_hld_caller, dev, (HLD_SDEC_MODULE<<24)|(3<<16)|FUNC_SDEC_START, NULL);
}

INT32  sdec_stop(struct sdec_device *dev)
{
	jump_to_func(NULL, OS_hld_caller, dev, (HLD_SDEC_MODULE<<24)|(1<<16)|FUNC_SDEC_STOP, NULL);

}

INT32  sdec_pause(struct sdec_device *dev)
{
	jump_to_func(NULL, OS_hld_caller, dev, (HLD_SDEC_MODULE<<24)|(1<<16)|FUNC_SDEC_PAUSE, NULL);
}

#if 0 //this function be done in lib_subt.c
INT32  sdec_showonoff(struct sdec_device *dev,BOOL bOn)
{
	/* If device not running, exit */
	if ((dev->flags & HLD_DEV_STATS_UP) == 0)
	{
		return RET_FAILURE;
	}
	
	if (dev->showonoff)
	{
		return dev->showonoff(dev,bOn);
	}
	return RET_FAILURE;
}
#endif

#endif

#endif

